<template>
  <div>
    <!-- 查询框 -->
    <el-form :inline="true" :model="queryForm" class="demo-form-inline">

      <el-form-item label="房源搜索">
        <el-input v-model="queryForm.keyword" placeholder="地区 线路..." clearable></el-input>
      </el-form-item>
      <!--<el-form-item label="地铁线路">
        <el-input v-model="queryForm.subway" placeholder="8号线 10号线..." clearable></el-input>
      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" @click="querySubmit">查询</el-button>
      </el-form-item>
    </el-form>
    <!-- 列表 -->
    <el-table
        :data="tableData"
        style="width: 90%">
      <!-- 多选
      <el-table-column
      type="selection"
      ></el-table-column>-->

      <el-table-column width="100"
          label="#" prop="id"
      ></el-table-column>

      <el-table-column
          prop="highlightFields.title"
          label="标题">
          <template slot-scope="scope">
            <span v-html="scope.row.highlightFields.title[0]" v-if="scope.row.highlightFields.title"></span>
            <span v-html="scope.row.content.title" v-else></span>
          </template>
      </el-table-column>

      <el-table-column label="Img" prop="elevator" width="50">
        <template slot-scope="scope">
          <img :src="scope.row.content.img" width="50px;">
        </template>
      </el-table-column>

      <el-table-column
          prop="content.detailItem"
          label="detailItem">
      </el-table-column>

      <el-table-column
          prop="content.detailItemTag"
          label="detailItemTag">
      </el-table-column>

      <el-table-column
                       prop="content.price"
                       label="price">
      </el-table-column>

      <el-table-column
                       prop="content.detailItemBotTag"
                       label="detailItemBotTag">
      </el-table-column>




    </el-table>

    <el-pagination
        :page-count="pageCount"
        :current-page="queryForm.current"
        :total="total"
        :page-size="queryForm.pageSize"
        @current-change="gotoPage"
        layout="prev, pager, next">
    </el-pagination>

    <div>
      <!-- <el-button size="mini" type="danger" @click="batchDel()">批删</el-button> -->
      <!--<el-button size="mini" @click="spider()">房源抓取</el-button>-->
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return {
      //查询条件
      queryForm:{
        title:null,
        pageNum:1,
        pageSize:5
      },
      //列表数据
      tableData:[],
      //table选择数据Id数组
      selecteIds:[],
      total:1,
      //总页数
      pageCount:1,
      houseTypeList:[
      {code:'jiZhShi', name: '集中式'},
      {code:'fenSanShi', name: '分散式'},
    ]
    }
  },
  methods:{
    gotoPage(current){
      this.queryForm.pageNum = current;
      this.list();
    },
    querySubmit(){
      //发送ajax请求，根据queryForm查询数据
      console.log(this.queryForm);
      if (this.queryForm.title == "") {
        this.queryForm.title = null;
      }
      this.queryForm.pageNum=1;
      this.list();

    },
    //列表页数据
    list(){
      this.axios.get("house-anjuke/keyword",{params: this.queryForm}).then(res=>{
        this.tableData = res.data.data.searchHits;
        this.total = res.data.data.totalHits;
      })
    }
  },
  created(){
    this.list();
  }
}
</script >

<style scoped>

</style>
